package com.ruoyi.web.controller.inventory;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.inventory.domain.Allot;
import com.ruoyi.inventory.service.AllotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/allot")
public class AllotController extends BaseController
{
    @Autowired
    private AllotService tAllotService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("select")
    public TableDataInfo list(String document){
        startPage();
        List<Allot> allots = tAllotService.selectTAllot(document);
        return getDataTable(allots);
    }

    /**
     * 新增调拨
     */
    @PostMapping("add")
    public AjaxResult add(@RequestBody Allot allot)
    {
        System.out.println(allot);
        return toAjax(tAllotService.insertTAllot(allot));
    }

    /**
     * 删除调拨
     */
    @DeleteMapping("del")
    public AjaxResult remove(Long id)
    {
        return toAjax(tAllotService.deleteTInventoryAllotById(id));
    }

    /**
     * 修改调拨
     */
    @PutMapping("up")
    public AjaxResult edit(@RequestBody Allot allot)
    {
        System.out.println(allot);
        return toAjax(tAllotService.updateTAllot(allot));
    }
}
